/*
 *  Copyright 2020-2021 Li Fei
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.pengshun.modules.domain;

//import cn.hutool.core.bean.BeanUtil;
//import cn.hutool.core.bean.copier.CopyOptions;
import com.fasterxml.jackson.annotation.JsonFormat;
//import com.pengshun.base.BaseEntity;
import com.pengshun.modules.common.Level;
import com.pengshun.modules.common.ShowPosition;
import com.pengshun.modules.common.TransportIsShow;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @author zhagning
 * @description 货运表
 * @date 2020-10-29
 **/
@Entity
@Data
@Table(name = "ps_transport")
@ApiModel("货运表")
public class Transport   implements Serializable {

    @Id
    @Column(name = "transport_id")
    @ApiModelProperty(value = "主键")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    private String shipAddress;

    private String isTax;
    private String takeType;
    private String isOpen;
    @ApiModelProperty(value = "用户Id")
    private Long userId;
    private Long orderAllotTransportId;

    @ApiModelProperty(value = "运单号")
    private String transportNo;

    @ApiModelProperty(value = "商户ID")
    private Long merchantId;

    @ApiModelProperty(value = "商户名称")
    private String merchantName;

    @Column(length = 30)
    @ApiModelProperty(value = "发货人省")
    protected String shipProvince;
    @Column(length = 10)
    @ApiModelProperty(value = "发货人省adcode")
    protected String shipProvinceAdcode;

    @Column(length = 30)
    @ApiModelProperty(value = "发货人市")
    protected String shipCity;

    @Column(length = 10)
    @ApiModelProperty(value = "发货人市Adcode")
    protected String shipCityAdcode;

    @Column(length = 30)
    @ApiModelProperty(value = "发货人区")
    protected String shipDistrict;
    private String shipName;
    private String shipPhone;
    @ApiModelProperty(value = "发货单位")
    private Integer shippingCompany;
    @ApiModelProperty(value = "收货单位")
    private Integer receiveCompany;
    @Column(length = 10)
    @ApiModelProperty(value = "发货人区编码")
    protected String shipDistrictAdcode;

    @ApiModelProperty(value = "发货人纬度")
    @Column(name = "ship_lngx")
    protected Double shipLngX;

    @ApiModelProperty(value = "发货人经度")
    @Column(name = "ship_laty")
    protected Double shipLatY;

    @Column(length = 300)
    @ApiModelProperty(value = "发货人详细地址")
    protected String shipDetailAddress;

    @Column(length = 30)
    @ApiModelProperty(value = "收货人省")
    protected String receiveProvince;

    @Column(length = 10)
    @ApiModelProperty(value = "收货人省Adcode")
    protected String receiveProvinceAdcode;

    @Column(length = 30)
    @ApiModelProperty(value = "收货人市")
    protected String receiveCity;

    @Column(length = 10)
    @ApiModelProperty(value = "收货人市Adcode")
    protected String receiveCityAdcode;

    @Column(length = 30)
    @ApiModelProperty(value = "收货人区")
    protected String receiveDistrict;

    @Column(length = 10)
    @ApiModelProperty(value = "收货人区编码")
    protected String receiveDistrictAdcode;

    @Column(length = 30)
    @ApiModelProperty(value = "收货人乡镇")
    protected String receiveTownship;

    @ApiModelProperty(value = "收货人纬度")
    @Column(name = "receive_lngx")
    protected Double receiveLngX;

    @ApiModelProperty(value = "收货人经度")
    @Column(name = "receive_laty")
    protected Double receiveLatY;

    @Column(length = 300)
    @ApiModelProperty(value = "收货人详细地址")
    protected String receiveDetailAddress;
    private String receiveAddress;
    private String receiveName;
    private String receivePhone;
    @ApiModelProperty(value = "运价（元/吨）")
    private BigDecimal freightPrice;
    private BigDecimal price;

    @ApiModelProperty(value = "货物名")
    private String name;
    private BigDecimal otherFee;
    private Integer needCar;
    @ApiModelProperty(value = "抢单")
    private Integer isGrabSingle = TransportIsShow.ZERO_STATUS;

    @ApiModelProperty(value = "抢单时间")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date startGrabSingle;

    @ApiModelProperty(value = "抢单时间")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date endGrabSingle;

    private String qrCode;

    @ApiModelProperty(value = "车辆类型Id")
    private Long vehicleTypeId;

    @ApiModelProperty(value = "车辆类型名")
    private String vehicleTypeName;

    @ApiModelProperty(value = "车辆长度Id")
    private String vehicleLengthId;

    @ApiModelProperty(value = "车辆长度名")
    private String vehicleLengthName;

    @ApiModelProperty("货运分类")
    private String freightTypeName;

    @ApiModelProperty("货运分类Code")
    private String freightTypeCode;

    @ApiModelProperty(value = "货物类型名称")
    private String freightTransportName;

    @ApiModelProperty(value = "货物类型编码")
    private String freightTransportCode;

    @ApiModelProperty(value = "需要车辆")
    private Integer needVehicleNumber;

    @ApiModelProperty(value = "货物重量")
    private BigDecimal weight;
    @ApiModelProperty(value = "货物总重量")
    private BigDecimal totalNumber;

    @ApiModelProperty(value = "信息费")
    private BigDecimal infoFee;

    @ApiModelProperty(value = "装车费")
    private BigDecimal loadFee;

    @ApiModelProperty(value = "卸车费")
    private BigDecimal unloadFee;

    @ApiModelProperty(value = "磅费")
    private BigDecimal poundsFee;

    @ApiModelProperty(value = "信息类型 0 收费 1 免费")
    private Integer infoType;

    @ApiModelProperty(value = "备注")
    private String remark;

    @ApiModelProperty(value = "是否显示")
    private Integer isShow = TransportIsShow.ONE_STATUS;

    @ApiModelProperty(value = "发布状态")
    private Integer status;

    @ApiModelProperty(value = "是否指定货运表")
    private Integer isAppoint;

    @ApiModelProperty(value = "发布时间")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date releaseTime;

    private Long orderId;

    private Integer joinMouthTime;

    private Integer loadCarTime;

    private Integer lowWeight;

    private Integer isPremium;

    private BigDecimal premiumPrice;

    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date premiumStartDate;

    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date premiumEndDate;

    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date startDate;

    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date endDate;

    @ApiModelProperty(value = "显示位置")
    private Integer showPosition = ShowPosition.ZERO_STATUS;

    @ApiModelProperty(value = "等级")
    private Integer level = Level.ZERO_STATUS;

    @ApiModelProperty(value = "排序")
    private Integer sort;

    @ApiModelProperty(value = "是否预约上架")
    private Integer isUp;
    @ApiModelProperty(value = "油卡比")
    private Integer oilProportion;
    @ApiModelProperty(value = "现金比")
    private Integer cashProportion;
    @ApiModelProperty(value = "是否承包0否1是")
    private Integer isContract;
    @ApiModelProperty(value = "允许差异吨位")
    private BigDecimal allowDiff;

    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date upTime;

    @ApiModelProperty(value = "是否预约下架")
    private Integer isDown;

    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private Date downTime;
    private Date createTime;
    private String startAddress;
    private String endAddress;

    /*@OneToMany(cascade = {CascadeType.PERSIST, CascadeType.REMOVE})
    @JoinColumn(name = "transport_id")
    private List<TransportLabel> transportLabels;*/
    @Transient
    private List<TransportAssign> transportAssigns;
//
//    public void copy(Transport source) {
//        BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
//    }
}